// components/my-datetime-picker/index.js
Component({

    /**
     * 组件的属性列表
     */
    properties: {
        type: {
            type: String
        },
        dataValue: {
            type: String
        },
    },

    /**
     * 组件的初始数据
     */
    data: {
        dateTime: '',
        startValue: '',
        endValue: ''
    },

    observers: {
        dataValue: function (dataValue) {
            this.setData({
                dateTime: dataValue
            });
        },
        type: function (type) {
            let startValue = '';
            let endValue = '';
            if (type == 'date') {
                startValue = '2024-12-12';
                const today = new Date();
                endValue += today.getFullYear() + 1;
                endValue += '-';
                endValue += ('0' + (today.getMonth() + 1)).slice(-2);
                endValue += '-';
                endValue += ('0' + today.getDate()).slice(-2);
            }
            if (type == 'time') {
                startValue = '00:01';
                startValue = '23:59';
            }
            this.setData({
                startValue,
                endValue
            });
        }
    },

    /**
     * 组件的方法列表
     */
    methods: {

        bindDateTimeChange: function (e) {
            this.setData({
                dateTime: e.detail.value
            })
            this.triggerEvent('OnChange', this.data.dateTime);
        }
    }
})